const nodeMailer = require('nodemailer')

async function sendMail(sendInfo) {
  const transporter = nodeMailer.createTransport({
    host: 'smtp.qq.com',
    port: 587,
    secure: false,
    auth: {
      user: 'jarvanzx@qq.com', // generated ethereal user
      pass: 'pdoilrgpmoxwfiie' // generated ethereal password
    }
  })

  const info = await transporter.sendMail({
    from: '"认证邮件" <jarvanzx@qq.com>',
    to: sendInfo.email,
    subject: '欢迎注册juejin APP',
    text: `您的验证码是：${sendInfo.code}, 30分钟内有效， 请勿告知他人哦！`
  })

  return info.messageId
}

module.exports = sendMail